<?php 
include_once("conexion.class.php");

class Role{
 //constructor	
 	var $con;
 	function Role(){
 		$this->con=new DBManager;
 	}

	function insertar($campos){
		if($this->con->conectar()==true){	
			$campos[0]=str_replace(" ", "_", $campos[0]);
			return mysql_query("INSERT INTO roles (role, descripcion) VALUES ('".$campos[0]."', '".$campos[1]."')");
		}
	}
	
	function actualizar($campos,$id){
			

		if($this->con->conectar()==true){
			
			$campos[0]=str_replace(" ", "_", $campos[0]);
			return mysql_query("UPDATE roles SET role = '".$campos[0]."', descripcion='".$campos[1]."' WHERE id = ".$id);
		}
	}
	
	
	function mostrar_role($id){
		if($this->con->conectar()==true){
			return mysql_query("SELECT * FROM roles WHERE id=".$id);
		}
	}

	function mostrar_roles(){
		if($this->con->conectar()==true){
			return mysql_query("SELECT * FROM roles");
		}
	}

	function eliminar($id){
		if($this->con->conectar()==true){
			return mysql_query("DELETE FROM roles WHERE id=".$id);
		}
	}
}
?>